package dataStruct.queue.ex3;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by thinkpad on 2016/9/15.
 */
public class MsgTable {
    public HashMap<String, MsgBody> getMsgMap() {
        return msgMap;
    }

    public MsgTable(HashMap<String, MsgBody> msgMap) {
        this.msgMap = msgMap;
    }

    private HashMap<String, MsgBody> msgMap = new HashMap<String, MsgBody>();

    void add(MsgBody msgBody) {
        msgMap.put(msgBody.getUuid(), msgBody);
    }

    void del(String uuid) {
        msgMap.remove(uuid);
    }

    MsgBody get(String uuid) {
        return msgMap.get(uuid);
    }

    void replaceState(String key, State state) {
        MsgBody msgBody = get(key);
        MsgBody newMsg = new MsgBody(msgBody.getUuid(), state, msgBody.getBody(),msgBody.getName());
        msgMap.put(msgBody.getUuid(), newMsg);
    }
}
